package cn.controlsys;


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Author: shanzheng <br/>
 * Description: <br/>
 * Date： 18:05 2018/8/3.<br/>
 * Modified By: <br/>
 */
public class TestCode {
    public static void main(String[] args) throws IOException {
        System.out.println("你好");

        long startLong = System.currentTimeMillis();
//
		long num = 231181000001L;
		long max_num = 231181005001L;

		File f = new File("D://work/sn.txt"); //sn，设备号写入到sn.txt
		FileWriter fw = new FileWriter(f,false);
		if(!f.exists())
		f.createNewFile();

		File fpwd = new File("D://work/sn,pwd.txt"); //sn，密码拼接并写入到sn,pwd.txt
		FileWriter fwpwd = new FileWriter(fpwd,false);
		if(!fpwd.exists())
		fpwd.createNewFile();

		File fileDeviceAll = new File("D://work/device,all.txt");// 写入数据库的值文件
		FileWriter fileDeviceAllWrite = new FileWriter(fileDeviceAll,false);
		if (!fileDeviceAll.exists()) fileDeviceAll.createNewFile();

		String sn = null;
		int count = 0;
		WIPMAPMD5 d = new WIPMAPMD5();
		long sLong = 0;
		long eLong = 0;
		while (num < max_num) {
//			sn = "0"+String.valueOf(num);
			sn = String.valueOf(num);
			fw.write(sn);
			fw.write("\r\n");

			sLong = System.currentTimeMillis();
			String pwd = d.returnMD5(sn);
			String w = sn + ","+pwd;
			fwpwd.write(w);
			fwpwd.write("\r\n");

			// 写入数据的地方需要根据设备使用情况来生成文件
			// TODO (设备号，密码，多大电流，设备类型:0-电表1-水表2-插座3-门锁4-林洋5-其他，
			// TODO 是否生产:1是 0否，是否运营:1是0否，是否支持2G：1支持)
			String deviceAll = sn + ","+pwd + ",rp60,4,1,0,2018-09-28 15:57:28,2018-09-28 15:57:28,0";
			fileDeviceAllWrite.write(deviceAll);
			fileDeviceAllWrite.write("\r\n");
			eLong = System.currentTimeMillis();
			System.out.println(w + "生成密码耗时"+(eLong - sLong)+"毫秒");

			count ++;
			num++;
		}
		fw.close();
		fwpwd.close();
		long endLong = System.currentTimeMillis();
		System.out.println("生成设备号"+count+"张 耗时：" + (endLong - startLong) + " 毫秒");
    }
}
